﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebCore.Models.ViewModels.Account.Admin;
using WebCore.Models.DataEntities;
using WebCore.Models.DataManagers;
using WebCore.App_Start;

namespace WebCore.Models.ViewModels.Admin
{
    public class UserListViewModel
    {
        public _UserListPartialViewModel UserListPartialViewModel { get; set; }
        public string FilterKey { get; set; }
        public string FilterBy { get; set; }
        public string FilterRole { get; set; }
        public string FilterState { get; set; }
        public int? FilterPage { get; set; }

        public UserListViewModel()
        {
            UserListPartialViewModel = new _UserListPartialViewModel();
            
        }

        public UserListViewModel(string key, string by, string role, string state, int? page)
        {
            UserListPartialViewModel = new _UserListPartialViewModel();
            FilterKey = key==null?"":key.Trim();
            FilterBy = by??"";
            FilterRole = role??"";
            FilterState = state??"";
            FilterPage = page;
            var pageNumber = page ?? 1;
            List<UserDetail> userList = AccountManager.FilterUserDetails(FilterKey, FilterBy, FilterRole, FilterState);
            UserListPartialViewModel.UserDetails = new PagedList.PagedList<UserDetail>(userList, pageNumber, MyAppConfig.Admin_PageSize);
        }
    }
}